package math.vectorSpace.R2;

import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;

public class Segment2D {

    private Point2D start, end;

    /**
     * Constructs a segment from a start point and an end point.
     * 
     * @param start a Point2D specifying the start point of this segment
     * @param end a Point2D specifying the end point of this segment
     */
    public Segment2D(Point2D start, Point2D end) {
        this.start = start;
        this.end = end;
    }

    /**
     * Constructs a segment from coordinates that define the start point and end point
     * 
     * @param sX the x-coordinate of the start point
     * @param sY the y-coordinate of the start point
     * @param eX the x-coordinate of the end point
     * @param eY the y-coordinate of the end point
     */
    public Segment2D(double sX, double sY, double eX, double eY) {
        start = new Point2D(sX, sY);
        end = new Point2D(eX, eY);
    }

    public Point2D getStart() {
        return start;
    }

    public Point2D getEnd() {
        return end;
    }

    public double getX1() {
        return start.getX();
    }

    public double getY1() {
        return start.getY();
    }

    public double getX2() {
        return end.getX();
    }

    public double getY2() {
        return end.getY();
    }

    public Line2D convertToLine() {
        return new Line2D(start, end);
    }

    public void draw(Graphics2D g) {
        g.setStroke(new BasicStroke(3.0f));
        g.drawLine((int) this.start.getX(), (int) this.start.getY(), 
                (int) this.end.getX(), (int) this.end.getY());
    }

    public boolean isSelected(Point mouseLocation) {
        return false;
    }

    public void selected(Point mouseLocation) {
        
    }

    public void mouseClicked(Point mouseLocation) {
        
    }

    public void setIcon(Image newImg) {
    }

    public Image getIcon() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
